﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace PineLake.Drmwe.Encrypts.SHA1Hash
{
    public class SHA1
    {
        /// <summary>
        /// SHA1加密
        /// </summary>
        /// <param name="EncryptStr"></param>
        /// <returns></returns>
        /// 
        [Obsolete]
        public static string Encrypt(string EncryptStr)
        {
            // 第一种方式
            byte[] byteArray = Encoding.UTF8.GetBytes(EncryptStr);
            using (HashAlgorithm hashAlgorithm = new SHA1CryptoServiceProvider())
            {
                byteArray = hashAlgorithm.ComputeHash(byteArray);
                StringBuilder stringBuilder = new(256);
                foreach (byte item in byteArray)
                {
                    stringBuilder.AppendFormat("{0:x2}", item);
                }
                hashAlgorithm.Clear();
                return stringBuilder.ToString();
            }
        }
    }
}
